package dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import DButil.DBConnection;
import bean.User;

public class UpdateUser {
	public int Update(int id,User user) {
		int row=0;
		String sql="update users set name = ?, sex =?  where id =?";
		Connection connection=DBConnection.getConnection();
		try {
			PreparedStatement pstm=connection.prepareStatement(sql);
			pstm.setInt(3, id);
			pstm.setString(1, user.getName());
			pstm.setString(2, user.getSex());
			row=pstm.executeUpdate();
			
		} catch (SQLException e) {
			System.out.println("UpdateUser error,massage is:"+e.getMessage());
		}
		
		
		
		return row;			
	}

}
